#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
typedef long long ll;
const int T = 20, N = 1e5, M = 1e5, L = 1e6, maxV = 1e3;
int t, n, m;
double l, V;
double d[N + 5], p[M + 5];
double v[N + 5], a[N + 5];
pair<int, int> CtoD[N + 5];

int bs(double x, string opt) {
    int L = 1, R = m + 1, mid;
    while(L < R) {
        int mid = (L + R) >> 1;
        if(opt == ">") {
            if(p[mid] > x) {
                R = mid - 1;
            } else {
                L = mid + 1;
            }
        } else if(opt == ">=") {
            if(p[mid] >= x) {
                R = mid;
            } else {
                L = mid + 1;
            }
        }
    }
    return L;
}

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while(t--) {
        cin >> n >> m >> l >> V;
        for(int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        p[m + 1] = inf;
        for(int i = 1; i <= n; i++) {
            int st, ed;
            if(a[i] == 0) {
                st = bs(d[i], ">="), ed = m;
                if(v[i] <= V) {
                    CtoD[i] = make_pair(m + 2, m + 2);
                } else {
                    CtoD[i] = make_pair(st, ed);
                }
                continue;
            }
            double s = d[i] + (V * V * 1e8 - v[i] * v[i] * 1e8) / (2.0000000 * a[i]) / 1e8;
            if(a[i] > 0) {
                if(s > l) {
                    CtoD[i] = make_pair(m + 2, m + 2);
                } else if(v[i] > V) {
                    CtoD[i] = make_pair(bs(d[i], ">="), m);
                } else {
                    st = bs(s, ">"), ed = m;
                    CtoD[i] = make_pair(st, ed);
                }
            } else {
                if(v[i] < V) {
                    CtoD[i] = make_pair(m + 2, m + 2);
                } else {
                    st = bs(d[i], ">="), ed = bs(s, ">=") - 1;
                    CtoD[i] = make_pair(st, ed);
                }
            }
        }
        int res1 = 0;
        for(int i = 1; i <= n; i++) {
            if(CtoD[i].first <= CtoD[i].second && CtoD[i].first <= m && CtoD[i].second <= m) {
                res1++;
            } else {
                CtoD[i].first = CtoD[i].second = -inf;
            }
        }
        int rest = 0;
        sort(CtoD + 1, CtoD + n + 1);
        int i = n, pre = n - res1 + 1;
        while(i >= pre) {
            rest++;
            int pl = CtoD[i].first;
            while(i >= pre && CtoD[i].second >= pl) {
                i--;
            }
        }
        cout << res1 << ' ' << m - rest << endl;
    }
    return 0;
}